//导入相关包
import Vue from 'vue'
import VueRouter from 'vue-router'
import HotNews from '@/views/HotNews.vue'
import SportsNews from '@/views/SportsNews'
import EntertainmentNews from '@/views/EntertainmentNews'
import EconomicsNews from '@/views/EconomicsNews'
import NBABasketball from '@/views/NBABasketball.vue'
import CBABasketball from '@/views/CBABasketball.vue'
//设置VueRouter插件到Vue上
Vue.use(VueRouter)
//定义路由数组
const routes=[
    {
        path:'/hot',      //path为url路径，一级路由的path前面必须带/
        component:HotNews //component对应的组件
    },
    {
        path:'/sport',
        component:SportsNews,
        children:[
            {
                path:'nba', //二级路由前面的path，不能带/
                component:NBABasketball
            },
            {
                path:'cba',
                component:CBABasketball
            }
        ]
    },
    {
        path:'/entertainment',
        component:EntertainmentNews
    },
    {
        path:'/economics',
        component:EconomicsNews
    }
]
//实例化vueRouter(路由器)
const router=new VueRouter({
    routes:routes
})
//到处router
export default router
